package org.anyline.data.elasticsearch.adapter;

import org.anyline.adapter.KeyAdapter;
import org.anyline.data.adapter.DriverAdapter;
import org.anyline.data.adapter.init.DefaultDriverAdapter;
import org.anyline.data.param.ConfigStore;
import org.anyline.data.prepare.RunPrepare;
import org.anyline.data.run.Run;
import org.anyline.data.run.RunValue;
import org.anyline.data.runtime.DataRuntime;
import org.anyline.entity.*;
import org.anyline.metadata.*;
import org.anyline.metadata.type.DatabaseType;
import org.anyline.net.HttpResponse;
import org.anyline.util.BasicUtil;
import org.anyline.util.BeanUtil;
import org.anyline.util.FileUtil;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.RestClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.ResultSetMetaData;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@Repository("anyline.data.adapter.elasticsearch")
public class ElasticSearchAdapter extends DefaultDriverAdapter implements DriverAdapter {
    private static Logger log = LoggerFactory.getLogger(ElasticSearchAdapter.class);
    private RestClient client;

    @Override
    public DatabaseType type() {
        return DatabaseType.ElasticSearch;
    }
    public ElasticSearchAdapter(){
        super();
    }
    public ElasticSearchAdapter(RestClient client){
        this.client = client;
    }

    /*PUT /es_db
 {
 "mappings":{
     "properties":{
         "name":{"type":"keyword","index":true,"store":true},
         "sex":{"type":"integer","index":true,"store":true},
         "age":{"type":"integer","index":true,"store":true},
         "book":{"type":"text","index":true,"store":true},
         "address":{"type":"text","index":true,"store":true}
     }
 }
 }*/
    public boolean create(Table table, DataRow setting){
        boolean result = false;
        DataRow body = new DataRow(KeyAdapter.KEY_CASE.SRC);
        DataRow mappings = new DataRow(KeyAdapter.KEY_CASE.SRC);
        LinkedHashMap<String, Column> columns = table.getColumns();
        LinkedHashMap<String,DataRow> properties = new LinkedHashMap<>();
        for(Column column:columns.values()){
            DataRow col = new DataRow(KeyAdapter.KEY_CASE.SRC);
            String type = column.getFullType();
            Boolean index = column.getIndex();
            Boolean store = column.getStore();
            String analyzer = column.getAnalyzer();
            String searchAnalyzer = column.getSearchAnalyzer();
            if(BasicUtil.isNotEmpty(type)){
                col.put("type", type);
            }
            if(null != index){
                col.put("index", index);
            }
            if(null != store){
                col.put("store", store);
            }
            if(BasicUtil.isNotEmpty(analyzer)){
                col.put("analyzer", analyzer);
            }
            if(BasicUtil.isNotEmpty(searchAnalyzer)){
                col.put("search_analyzer", searchAnalyzer);
            }
            properties.put(column.getName(), col);
        }
        if(null != setting){
            body.put("settings", setting);
        }
        body.put("mappings", mappings);
        mappings.put("properties", properties);
        String json = body.toJSON();
        log.warn("[create index][map:{}]", json);
        Request request = new Request("PUT", "/"+table.getName());
        request.setJsonEntity(json);
        HttpResponse response = exe(request);
        if(response.getStatus() == 200){
            result = true;
        }
        return result;
    }
    public boolean drop(Table table){
        boolean result = false;
        Request request = new Request("DELETE", table.getName());
        HttpResponse response = exe(request);
        if(response.getStatus() == 200){
            result = true;
        }
        return result;
    }

    @Override
    public boolean rename(DataRuntime runtime, Table origin, String name) throws Exception {
        return false;
    }

    @Override
    public boolean create(DataRuntime runtime, View view) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, View view) throws Exception {
        return false;
    }

    @Override
    public boolean drop(DataRuntime runtime, View view) throws Exception {
        return false;
    }

    @Override
    public boolean rename(DataRuntime runtime, View origin, String name) throws Exception {
        return false;
    }

    @Override
    public boolean create(DataRuntime runtime, MasterTable meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, MasterTable meta) throws Exception {
        return false;
    }

    @Override
    public boolean drop(DataRuntime runtime, MasterTable meta) throws Exception {
        return false;
    }

    @Override
    public boolean rename(DataRuntime runtime, MasterTable origin, String name) throws Exception {
        return false;
    }

    @Override
    public boolean create(DataRuntime runtime, PartitionTable meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, PartitionTable meta) throws Exception {
        return false;
    }

    @Override
    public boolean drop(DataRuntime runtime, PartitionTable meta) throws Exception {
        return false;
    }

    @Override
    public boolean rename(DataRuntime runtime, PartitionTable origin, String name) throws Exception {
        return false;
    }

    @Override
    public boolean add(DataRuntime runtime, Column meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, Table table, Column meta, boolean trigger) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, Column meta) throws Exception {
        return false;
    }

    @Override
    public boolean drop(DataRuntime runtime, Column meta) throws Exception {
        return false;
    }

    @Override
    public boolean rename(DataRuntime runtime, Column origin, String name) throws Exception {
        return false;
    }

    @Override
    public boolean add(DataRuntime runtime, Tag meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, Table table, Tag meta, boolean trigger) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, Tag meta) throws Exception {
        return false;
    }

    @Override
    public boolean drop(DataRuntime runtime, Tag meta) throws Exception {
        return false;
    }

    @Override
    public boolean rename(DataRuntime runtime, Tag origin, String name) throws Exception {
        return false;
    }

    @Override
    public boolean add(DataRuntime runtime, PrimaryKey meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, PrimaryKey meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, Table table, PrimaryKey meta) throws Exception {
        return false;
    }

    @Override
    public boolean drop(DataRuntime runtime, PrimaryKey meta) throws Exception {
        return false;
    }

    @Override
    public boolean rename(DataRuntime runtime, PrimaryKey origin, String name) throws Exception {
        return false;
    }

    @Override
    public boolean add(DataRuntime runtime, ForeignKey meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, ForeignKey meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, Table table, ForeignKey meta) throws Exception {
        return false;
    }

    @Override
    public boolean drop(DataRuntime runtime, ForeignKey meta) throws Exception {
        return false;
    }

    @Override
    public boolean rename(DataRuntime runtime, ForeignKey origin, String name) throws Exception {
        return false;
    }

    @Override
    public boolean add(DataRuntime runtime, Index meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, Index meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, Table table, Index meta) throws Exception {
        return false;
    }

    @Override
    public boolean drop(DataRuntime runtime, Index meta) throws Exception {
        return false;
    }

    @Override
    public boolean rename(DataRuntime runtime, Index origin, String name) throws Exception {
        return false;
    }

    @Override
    public boolean add(DataRuntime runtime, Constraint meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, Constraint meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, Table table, Constraint meta) throws Exception {
        return false;
    }

    @Override
    public boolean drop(DataRuntime runtime, Constraint meta) throws Exception {
        return false;
    }

    @Override
    public boolean rename(DataRuntime runtime, Constraint origin, String name) throws Exception {
        return false;
    }

    @Override
    public boolean add(DataRuntime runtime, Trigger meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, Trigger meta) throws Exception {
        return false;
    }

    @Override
    public boolean drop(DataRuntime runtime, Trigger meta) throws Exception {
        return false;
    }

    @Override
    public boolean rename(DataRuntime runtime, Trigger origin, String name) throws Exception {
        return false;
    }

    @Override
    public boolean create(DataRuntime runtime, Procedure meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, Procedure meta) throws Exception {
        return false;
    }

    @Override
    public boolean drop(DataRuntime runtime, Procedure meta) throws Exception {
        return false;
    }

    @Override
    public boolean rename(DataRuntime runtime, Procedure origin, String name) throws Exception {
        return false;
    }

    @Override
    public boolean create(DataRuntime runtime, Function meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, Function meta) throws Exception {
        return false;
    }

    @Override
    public boolean drop(DataRuntime runtime, Function meta) throws Exception {
        return false;
    }

    @Override
    public boolean rename(DataRuntime runtime, Function origin, String name) throws Exception {
        return false;
    }

    /*
PUT index_user/_bulk
{"index":{"_index":"index_user", "_id":"10011"}}
{"id":1001, "name":"a b", "age":20}
{"index":{"_index":"index_user", "_id":"10012"}}
{"id":1002, "name":"b c", "age":20}
{"index":{"_index":"index_user", "_id":"10013"}}
{"id":1003, "name":"c d", "age":30}*/
    public boolean inserts(String table, Collection list){
        boolean result = false;
        String pk = "_id";
        String method = "PUT";
        String endpoint = table+"/_bulk";
        String body = null;
        StringBuilder builder = new StringBuilder();
        for(Object entity:list){
            Object _id = BeanUtil.getFieldValue(entity, pk);
            if (null == _id) {
                pk = "id";
                _id = BeanUtil.getFieldValue(entity, pk);
            }
            builder.append("{\"index\":{\"_index\":\"").append(table).append("\", \"_id\":\"").append(_id).append("\"}}\n");
            builder.append(BeanUtil.object2json(entity)).append("\n");
        }
        Request request = new Request(
                method,
                endpoint);
        body = BeanUtil.object2json(builder.toString());
        request.setJsonEntity(body);
        HttpResponse response = exe(request);
        if(response.getStatus() == 200 ||  response.getStatus() == 201){
            result = true;
        }
        return result;
    }

    /**
     *PUT index_user/_bulk
     * {"index":{"_index":"index_user", "_id":"10011"}}
     * {"id":1001, "name":"a b", "age":20}
     * {"index":{"_index":"index_user", "_id":"10012"}}
     * {"id":1002, "name":"b c", "age":20}
     * {"index":{"_index":"index_user", "_id":"10013"}}
     * {"id":1003, "name":"c d", "age":30}
     * @param table
     * @param set
     * @return
     */
    public boolean insert(String table, DataSet set){
        boolean result = false;
        String method = "PUT";
        String endpoint = "*/_bulk";
        String body = null;
        StringBuilder builder = new StringBuilder();
        for(DataRow row:set){
            String pk = "_id";
            Object _id = BeanUtil.getFieldValue(row, pk);
            if (null == _id) {
                pk = "id";
                _id = BeanUtil.getFieldValue(row, pk);
            }
            row.remove("_id");
            builder.append("{\"index\":{\"_index\":\"").append(table).append("\", \"_id\":\"").append(_id).append("\"}}\n");
            builder.append(row.toJSON()).append("\n");
        }
        Request request = new Request(
                method,
                endpoint);
        body = builder.toString();
        request.setJsonEntity(body);
        HttpResponse response = exe(request);
        return result;
    }
    public boolean insert(String table, DataRow entity){
        boolean result = false;
        String pk = "_id";
        String method = "POST";
        String endpoint = null;
        String body = null;
        //一般需要设置用于索引的主键 如法规id = l100 问答id = q100
        Object _id = BeanUtil.getFieldValue(entity, pk);
        if (null == _id) {
            pk = "id";
            _id = BeanUtil.getFieldValue(entity, pk);
        }
        endpoint = table + "/_doc/";
        if (BasicUtil.isNotEmpty(_id)) {
            method = "PUT";
            endpoint += _id;
        }
        entity.remove("_id");
        Request request = new Request(
                method,
                endpoint);
        body = BeanUtil.object2json(entity);
        request.setJsonEntity(body);
        HttpResponse response = exe(request);
        if(BasicUtil.isEmpty(_id)){
            DataRow row = DataRow.parse(response.getText());
            _id = row.getString(pk);
            if(BasicUtil.isNotEmpty(_id)){
                BeanUtil.setFieldValue(entity, pk, _id);
            }
        }
        return result;
    }
    private HttpResponse exe(Request request){
        HttpResponse result = new HttpResponse();
        try {
            Response response = client.performRequest(request);
            int status = response.getStatusLine().getStatusCode();
            result.setStatus(status);
            //{"_index":"index_user","_id":"102","_version":3,"result":"updated","_shards":{"total":2,"successful":2,"failed":0},"_seq_no":9,"_primary_term":1}
            String content = FileUtil.read(response.getEntity().getContent()).toString();
            result.setText(content);
            log.warn("[status:{}]", status);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
    public DataRow get(String table, String id){
        DataRow result = null;
        String method = "GET";
        String endpoint = "/"+table+"/_doc/"+id;
        Request request = new Request(
                method,
                endpoint);
        HttpResponse response = exe(request);
        if(response.getStatus() == 200) {
            String txt = response.getText();
            DataRow row = DataRow.parseJson(txt);
            result = row.getRow("_source");
        }
        return result;
    }
    public DataSet search(String table, DataRow body, PageNavi page){
        DataSet set = null;
        if(null != page){
            body.put("from", page.getFirstRow());
            body.put("size", page.getPageRows());
        }
        String method = "POST";
        String endpoint = table+"/_search";
        Request request = new Request(
                method,
                endpoint);
        String json = body.toLowerKey(true).toJSON();
        log.warn("[search][body:{}]", body);
        request.setJsonEntity(json);
        HttpResponse response = exe(request);
        if(response.getStatus() == 200) {
            String txt = response.getText();
            DataRow row = DataRow.parseJson(txt);
            Object total = row.recursion("hits", "total", "value");
            if(null == page){
                page = new DefaultPageNavi();
            }
            page.setTotalRow(BasicUtil.parseInt(total,0));
            set = new DataSet();
            set.setNavi(page);
            DataSet hits = row.getRow("hits").getSet("hits");
            for(DataRow hit:hits){
                DataRow item = hit.getRow("_source");
                item.put("_id", hit.get("_id"));
                DataRow highlight = hit.getRow("highlight");
                if(null != highlight){
                    for(String key:highlight.keySet()){
                        List vals = highlight.getList(key);
                        if(null != vals && vals.size()>0){
                            item.put(key, vals.get(0));
                        }
                    }
                }
                set.add(item);
            }

        }
        return set;
    }
    /*GET _analyze
{
  "analyzer": "ik_max_word",
  "text": ["马铃薯真好吃"]
}
*/
    public LinkedHashMap<String,DataRow> analyze(String key){
        return analyze(key, null);
    }
    public LinkedHashMap<String,DataRow> analyze(String key, String mode){
        LinkedHashMap<String,DataRow> maps = new LinkedHashMap<>();
        DataRow body = new DataRow(KeyAdapter.KEY_CASE.SRC);
        if(BasicUtil.isEmpty(mode)){
            mode = "ik_smart";
        }
        body.put("analyzer", mode);
        body.put("text", new String[]{key});

        Request request = new Request(
                "GET",
                "_analyze");
        request.setJsonEntity(BeanUtil.object2json(body));
        HttpResponse response = exe(request);
        if(response.getStatus() == 200) {
            DataRow row = DataRow.parseJson(response.getText());
            DataSet tokens = row.getSet("tokens");
            for(DataRow token:tokens){
                String k = token.getString("token");
                if(k.length() > 1){
                    maps.put(k, token);
                }
            }
        }
        return maps;
    }


    @Override
    public long insert(DataRuntime runtime, String random, Object data, ConfigStore configs, Run run, String[] pks) {
        return 0;
    }

    @Override
    public long insert(DataRuntime runtime, String random, Object data, ConfigStore configs, Run run, String[] pks, boolean simple) {
        return 0;
    }

    @Override
    public long save(DataRuntime runtime, String random, String dest, Object data, ConfigStore configs, boolean checkPrimary, List<String> columns) {
        return 0;
    }

    @Override
    public Run buildUpdateRunFromEntity(DataRuntime runtime, String dest, Object obj, ConfigStore configs, boolean checkPrimary, LinkedHashMap<String, Column> columns) {
        return null;
    }

    @Override
    public Run buildUpdateRunFromDataRow(DataRuntime runtime, String dest, DataRow row, ConfigStore configs, boolean checkPrimary, LinkedHashMap<String, Column> columns) {
        return null;
    }

    @Override
    public Run buildUpdateRunFromCollection(DataRuntime runtime, int batch, String dest, Collection list, ConfigStore configs, boolean checkPrimary, LinkedHashMap<String, Column> columns) {
        return null;
    }

    @Override
    public long update(DataRuntime runtime, String random, String dest, Object data, ConfigStore configs, Run run) {
        return 0;
    }

    @Override
    public DataSet querys(DataRuntime runtime, String random, Procedure procedure, PageNavi navi) {
        return null;
    }

    @Override
    public <T> EntitySet<T> selects(DataRuntime runtime, String random, RunPrepare prepare, Class<T> clazz, ConfigStore configs, String... conditions) {
        return null;
    }

    @Override
    public List<Map<String, Object>> maps(DataRuntime runtime, String random, RunPrepare prepare, ConfigStore configs, String... conditions) {
        return null;
    }

    @Override
    public String mergeFinalQuery(DataRuntime runtime, Run run) {
        return null;
    }

    @Override
    public RunValue createConditionLike(DataRuntime runtime, StringBuilder builder, Compare compare, Object value) {
        return null;
    }

    @Override
    public Object createConditionFindInSet(DataRuntime runtime, StringBuilder builder, String column, Compare compare, Object value) {
        return null;
    }

    @Override
    public StringBuilder createConditionIn(DataRuntime runtime, StringBuilder builder, Compare compare, Object value) {
        return null;
    }

    @Override
    public DataSet select(DataRuntime runtime, String random, boolean system, String table, ConfigStore configs, Run run) {
        return null;
    }

    @Override
    public List<Map<String, Object>> maps(DataRuntime runtime, String random, ConfigStore configs, Run run) {
        return null;
    }

    @Override
    public Map<String, Object> map(DataRuntime runtime, String random, ConfigStore configs, Run run) {
        return null;
    }

    @Override
    public DataRow sequence(DataRuntime runtime, String random, boolean next, String... names) {
        return null;
    }

    @Override
    public long count(DataRuntime runtime, String random, RunPrepare prepare, ConfigStore configs, String... conditions) {
        return 0;
    }

    @Override
    public long count(DataRuntime runtime, String random, Run run) {
        return 0;
    }

    @Override
    public boolean exists(DataRuntime runtime, String random, RunPrepare prepare, ConfigStore configs, String... conditions) {
        return false;
    }

    @Override
    public long execute(DataRuntime runtime, String random, RunPrepare prepare, ConfigStore configs, String... conditions) {
        return 0;
    }

    @Override
    public long execute(DataRuntime runtime, String random, int batch, ConfigStore configs, String sql, List<Object> values) {
        return 0;
    }

    @Override
    public boolean execute(DataRuntime runtime, String random, Procedure procedure) {
        return false;
    }

    @Override
    public long execute(DataRuntime runtime, String random, ConfigStore configs, Run run) {
        return 0;
    }

    @Override
    public long truncate(DataRuntime runtime, String random, String table) {
        return 0;
    }

    @Override
    public Run buildDeleteRunFromTable(DataRuntime runtime, int batch, String table, String column, Object values) {
        return null;
    }

    @Override
    public Run buildDeleteRunFromEntity(DataRuntime runtime, String table, Object obj, String... columns) {
        return null;
    }

    @Override
    public void fillDeleteRunContent(DataRuntime runtime, Run run) {

    }

    @Override
    public long delete(DataRuntime runtime, String random, ConfigStore configs, Run run) {
        return 0;
    }

    @Override
    public void checkSchema(DataRuntime runtime, DataSource dataSource, Table table) {

    }

    @Override
    public void checkSchema(DataRuntime runtime, Connection con, Table table) {

    }

    @Override
    public void checkSchema(DataRuntime runtime, Table table) {

    }

    @Override
    public LinkedHashMap<String, Column> metadata(DataRuntime runtime, RunPrepare prepare, boolean comment) {
        return null;
    }

    @Override
    public LinkedHashMap<String, Database> databases(DataRuntime runtime, String random) {
        return null;
    }

    @Override
    public Database database(DataRuntime runtime, String random, String name) {
        return null;
    }

    @Override
    public <T extends Table> List<T> tables(DataRuntime runtime, String random, boolean greedy, String catalog, String schema, String pattern, String types, boolean strut) {
        return null;
    }

    @Override
    public <T extends Table> LinkedHashMap<String, T> tables(DataRuntime runtime, String random, String catalog, String schema, String pattern, String types, boolean strut) {
        return null;
    }

    @Override
    public List<String> ddl(DataRuntime runtime, String random, Table table, boolean init) {
        return null;
    }

    @Override
    public <T extends View> LinkedHashMap<String, T> views(DataRuntime runtime, String random, boolean greedy, String catalog, String schema, String pattern, String types) {
        return null;
    }

    @Override
    public List<String> ddl(DataRuntime runtime, String random, View view) {
        return null;
    }

    @Override
    public <T extends MasterTable> LinkedHashMap<String, T> mtables(DataRuntime runtime, String random, boolean greedy, String catalog, String schema, String pattern, String types) {
        return null;
    }

    @Override
    public List<String> ddl(DataRuntime runtime, String random, MasterTable table) {
        return null;
    }

    @Override
    public <T extends PartitionTable> LinkedHashMap<String, T> ptables(DataRuntime runtime, String random, boolean greedy, MasterTable master, Map<String, Object> tags, String name) {
        return null;
    }

    @Override
    public List<String> ddl(DataRuntime runtime, String random, PartitionTable table) {
        return null;
    }

    @Override
    public <T extends Column> LinkedHashMap<String, T> columns(DataRuntime runtime, String random, boolean greedy, Table table, boolean primary) {
        return null;
    }

    @Override
    public <T extends Column> List<T> columns(DataRuntime runtime, String random, boolean greedy, String catalog, String schema, String table) {
        return null;
    }

    @Override
    public <T extends Column> LinkedHashMap<String, T> columns(DataRuntime runtime, int index, boolean create, Table table, LinkedHashMap<String, T> columns, DataSet set) throws Exception {
        return null;
    }

    @Override
    public <T extends Column> List<T> columns(DataRuntime runtime, int index, boolean create, Table table, List<T> columns, DataSet set) throws Exception {
        return null;
    }

    @Override
    public <T extends Column> LinkedHashMap<String, T> columns(DataRuntime runtime, boolean create, LinkedHashMap<String, T> columns, Table table, String pattern) throws Exception {
        return null;
    }

    @Override
    public <T extends Column> LinkedHashMap<String, T> columns(DataRuntime runtime, String random, boolean create, Table table, LinkedHashMap<String, T> columns, List<Run> runs) {
        return null;
    }

    @Override
    public Column column(DataRuntime runtime, Column column, ResultSetMetaData rsm, int index) {
        return null;
    }

    @Override
    public <T extends Tag> LinkedHashMap<String, T> tags(DataRuntime runtime, String random, boolean greedy, Table table) {
        return null;
    }

    @Override
    public PrimaryKey primary(DataRuntime runtime, String random, boolean greedy, Table table) {
        return null;
    }

    @Override
    public <T extends ForeignKey> LinkedHashMap<String, T> foreigns(DataRuntime runtime, String random, boolean greedy, Table table) {
        return null;
    }

    @Override
    public <T extends Index> LinkedHashMap<String, T> indexs(DataRuntime runtime, String random, boolean greedy, Table table, String name) {
        return null;
    }

    @Override
    public <T extends Trigger> LinkedHashMap<String, T> triggers(DataRuntime runtime, String random, boolean greedy, Table table, List<Trigger.EVENT> events) {
        return null;
    }

    @Override
    public <T extends Procedure> LinkedHashMap<String, T> procedures(DataRuntime runtime, String random, boolean greedy, String catalog, String schema, String name) {
        return null;
    }

    @Override
    public <T extends Function> LinkedHashMap<String, T> functions(DataRuntime runtime, String random, boolean recover, String catalog, String schema, String name) {
        return null;
    }

    @Override
    public boolean create(DataRuntime runtime, Table meta) throws Exception {
        return false;
    }

    @Override
    public boolean alter(DataRuntime runtime, Table meta) throws Exception {
        return false;
    }

    @Override
    public boolean drop(DataRuntime runtime, Table meta) throws Exception {
        return false;
    }

    @Override
    public String concat(DataRuntime runtime, String... args) {
        return null;
    }
}
